using NUnit.Framework;
using RadaCode.SwissKnife.Random;

namespace SwissKnife.Tests
{
    [TestFixture]
    public class RandomWordSearcherTests
    {
        [Test]
        public void GetRandomWord()
        {
            var searcher = new RandomWordSearcher();
            var word = searcher.GetRandomWord();

            Assert.GreaterOrEqual(word.Length, 3);
        }

        [Test]
        public void GetRandomWordFromSpecialUrl()
        {
            var searcher = new RandomWordSearcher("http://www.forbes.com/europe_news/index.xml");
            var word = searcher.GetRandomWord();

            Assert.GreaterOrEqual(word.Length, 3);
        }

        [Test]
        public void GetNRandomWordsWithMinLength()
        {
            const int count = 15;
            const int minLength = 4;

            var searcher = new RandomWordSearcher("http://www.forbes.com/europe_news/index.xml", minLength);
            var words = searcher.GetRandomWords(count);

            Assert.AreEqual(count, words.Length);

            foreach (var word in words)
            {
                Assert.GreaterOrEqual(word.Length, minLength);
            }
        }
    }
}